<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" %>
<%@ page import="com.itheima.dao.pojo.User" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<!DOCTYPE html>
<!-- 网页使用的语言 -->
<html lang="zh-CN">
<head>
    <base href="<%=basePath%>"/>
    <!-- 指定字符集 -->
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>修改用户</title>

    <link href="css/bootstrap.min.css" rel="stylesheet">
    <script src="js/jquery-2.1.0.min.js"></script>
    <script src="js/bootstrap.min.js"></script>

</head>
<body>
<div class="container" style="width: 400px;">
    <h3 style="text-align: center;">修改联系人</h3>
    <form action="/user?method=updateUserById" method="post">
        <%--id   form表单中隐藏的内容--%>
            <input type="hidden" value="${requestScope.user.id}" name="id">


        <div class="form-group">
            <label for="name">姓名：</label>
            <input type="text" class="form-control" id="name" name="name" value="${requestScope.user.name} " />
        </div>


        <%
            //从转发过来的域中获取需要的值
            User user = (User) request.getAttribute("user");
            String sex = user.getSex();
            String s1 = "checked";
        %>
        <div class="form-group">
            <label>性别：</label>
            <input type="radio" name="sex" value="男" <%=sex.equals("男") ? s1 : null%>/>男
            <input type="radio" name="sex" value="女" <%=sex.equals("女") ? s1 : null%>/>女
        </div>

        <div class="form-group">
            <label for="age">年龄：</label>
            <input type="text" class="form-control" id="age" name="age" value="${requestScope.user.age}"/>
        </div>

        <%
            String address = user.getAddress();
            String s3 = "selected";
        %>
        <div class="form-group">
            <label for="address">籍贯：</label>
            <select name="address" class="form-control">
                <option value="广东"<%=address.equals("广东") ? s3 : null%>>广东</option>
                <option value="广西"<%=address.equals("广西") ? s3 : null%>>广西</option>
                <option value="湖南"<%=address.equals("湖南") ? s3 : null%>>湖南</option>
            </select>
        </div>

        <div class="form-group">
            <label for="qq">QQ：</label>
            <input type="text" readonly="readonly" class="form-control" name="qq"
                   value="${requestScope.user.qq}"/>
        </div>

        <div class="form-group">
            <label for="email">Email：</label>
            <input type="text" readonly="readonly" class="form-control" name="email"
                   value="${requestScope.user.email}"/>
        </div>

        <div class="form-group" style="text-align: center">
            <input class="btn btn-primary" type="submit" value="提交"/>
            <input class="btn btn-default" type="reset" value="重置"/>
            <input class="btn btn-default" type="button" value="返回"
                   onclick="window.history.go(-1)"/>
        </div>
    </form>
</div>
</body>
</html>




